﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAccessLayer
{
    public class SupplierDetailRepository
    {
        StationeryInventoryEntities1 ent;

        public SupplierDetailRepository()
        {
            ent = new StationeryInventoryEntities1();
        }

        #region Select Method

        public SupplierDetail GetSupplierDetailBySupplierIdAndItemCode(string supplierId, string itemCode)
        {
            SupplierDetail supplierDetail = new SupplierDetail();

            var sd = ent.SupplierDetails.Where(x => x.SupplierID == supplierId && x.ItemCode == itemCode);

            if (sd != null)
            {
                supplierDetail = sd.FirstOrDefault();
            }
            return supplierDetail;
        }

        public List<SupplierDetail> GetSupplierDetailByItemCode(string itemCode)
        {
            List<SupplierDetail> list = new List<SupplierDetail>();

            var supDetailList = ent.SupplierDetails.Where(x => x.ItemCode == itemCode);

            if (supDetailList != null)
            {
                list = supDetailList.ToList();
            }
            return list;
        }

        #endregion

    }
}
